<template>
  <div class="container-x-suit">
    <div class="container">
      <el-collapse v-model="activeNames">
        <el-collapse-item title="简    介" name="1">
          <div class="container-row">
            <div class="container-item img">
              <div class="img-box">
                <img :src="group.header.images[0]" height="100%">
              </div>
            </div>
            <div class="container-item detail">
              <div style="display: inline-block;">
                <div class="item">
                  <label>负责人：</label><span>{{group.header.name}}</span>
                </div>
                <div class="item">
                  <label><span class="spacing">电</span>话：</label><span>{{group.header.mask_phone}}</span>
                </div>
                <!-- <div class="item">
                  <label><span class="spacing">技</span>能：</label><span>{{group.teams.name}}</span>
                </div> -->
                <div class="item">
                  <label><span class="spacing">类</span>型：</label><span>{{group.teams.name}}</span>
                </div>
                <div class="item">
                  <label><span class="spacing">地</span>址：</label><span>{{group.header.city.name}}</span>
                </div>
                <div class="item">
                  <label><span class="spacing">人</span>数：</label><span>{{group.mens}}</span>
                </div>
                <div class="item">
                  <label><span class="spacing">星</span>级：</label><el-rate class="big" :value="group.level" disabled></el-rate>
                </div>
              </div>
            </div>
          </div>
        </el-collapse-item>
        <el-collapse-item title="详细信息" name="2">
          <div class="table-dev">
          <table border=1>
            <tr><th>序号</th><th>姓名</th><th>年龄</th><th>手机号</th></tr>
            <tr v-for="(item,index) in members" :key="index"><td>{{ index+1 }}</td><td>{{ item.name }}</td><td>{{ item.age }}</td><td>{{ item.mask_phone }}</td></tr>
          </table>
          </div>
        </el-collapse-item>
        <el-collapse-item title="过往工程" name="3">
          <div class="table-dev">
          <table border=1>
            <tr><th>序号</th><th>项目名称</th><th>项目地址</th><th>结束时间</th></tr>
            <tr v-for="(item,index) in items" :key="index"><td>{{ index+1 }}</td><td>{{ item.name }}</td><td>{{ item.real_city }}</td><td>{{ item.overed_at }}</td></tr>
          </table>
          </div>
        </el-collapse-item>
      </el-collapse>

      <!-- <div class="container-row">
        <div class="container-item des1">
          <h3>过往工程</h3>
          <div style="text-align: center;display: inline-block;">
            <p v-for="(item, index) in group.before" :key="item">{{ `${index + 1}. ${item}` }}</p>
          </div>
        </div>
        <div class="container-item">
          <img :src="requireImg('bzjs1.png')" class="full">
        </div>
      </div>
      <div class="container-row">
        <div class="container-item">
          <img :src="requireImg('bzjs2.png')" class="full">
        </div>
        <div class="container-item des2">
          <div class="center">
            <h3>虎匠评价</h3>
            <p>1、组织贯彻实施国家和公司指定的各项技术标准、规定、规范和技术质量管理制度；</p>
            <p>2、贯彻公司的管理方针，负责实施施工项目的质量计划，确保工程目标的实现；</p>
          </div>
        </div>
      </div> -->
    </div>
  </div>
</template>

<script>
import capData from './data'
import { requireImgMixin } from '@/common/js/mixin'
import { getDetails, getMembers, getItems } from '@/api/capintro'
export default {
  name: 'CapIntroDetail',
  mixins: [requireImgMixin],
  data() {
    return {
      group: {},
      activeNames: ['1'],
      members: [],
      items: []
    }
  },
  methods: {
    getData() {
      let ret = {}

      capData.forEach(row => {
        row.groups.forEach(group => {
          if (group.id === parseInt(this.$route.params.id)) {
            ret = group
          }
        })
      })

      return ret
    }
  },
  mounted() {
    getDetails(this.$route.params.id).then(response => {
      this.group = response.data
    })
    getMembers(this.$route.params.id).then(response => {
      this.members = response.data
    })
    getItems(this.$route.params.id).then(response => {
      this.items = response.data
    })
  },
  watch: {
    $route: {
      handler: function() {
        this.group = this.getData()
      },
      immediate: true
    }
  }
}
</script>

<style lang="stylus" scoped>
@import '~common/stylus/variable.styl';
.table-dev
  width 100%;
  table
    margin 0 auto;
    width 80%;
    tr,th
      text-align center
.container {
  padding: 0 20px 55px 20px;

  &:after {
    content: '';
    display: table;
    clear: both;
  }

  .container-row {
    display: flex;

    .img-box {
      overflow: hidden;
      margin: 0 auto;
      height: 326px;
      width: 234px;

      img {
        height: 100%;
      }
    }

    .container-item {
      flex: 1;
      text-align: center;

      .full {
        width: 100%;
        height: 100%;
      }

      .item {
        text-align: left;
        height: 50px;
        line-height: 50px;
        color: $color-text-rule;

        .spacing {
          letter-spacing: 24px;
        }

        .big {
          height: auto;
          display: inline-flex;
        }
      }

      &.img {
        padding: 55px 0;
      }

      &.detail {
        font-size: 24px;
        text-align: center;
        padding: 55px 0;

        label {
          width: 120px;
          display: inline-block;
          text-align: right;
        }
      }

      &.des1 {
        background-color: #387dc5;
        padding: 50px 0;
        color: #FFF;
        font-size: 18px;

        h3 {
          font-size: 24px;
          font-weight: bold;
          line-height: 50px;
        }

        p {
          text-align: left;
          line-height: 40px;
        }
      }

      &.des2 {
        background-color: #f5f5f5;
        font-size: 18px;

        .center {
          padding: 50px 80px;
          height: 100%;
          box-sizing: border-box;
        }

        h3 {
          font-size: 24px;
          font-weight: bold;
          line-height: 50px;
        }

        p {
          text-align: left;
          line-height: 1.5;
          padding: 15px 0;
          color: $color-text-rule;
        }
      }
    }
  }
}

@media (max-width: $media-smail) {
  .container-row {
    flex-direction: column;

    .container-item {
      &.detail {
        padding: 0 !important;
      }

      &.des2 {
        .center {
          padding: 50px 20px !important;
        }
      }
    }
  }
}
</style>
